So I'm finding it hard to explain how to make a time series of a shape feature, so here's some example code of what I mean.
So you're applying the code from this tutorial to your data. Right?
In [1]:
%config InlineBackend.figure_format = 'retina'
%matplotlib inline
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style('white')
from misshapen import shape, nonshape
In [5]:
x = np.load('./exampledata.npy') # voltage series
x = x[:10000]
Fs = 1000 # sampling rate
f_range = (13,30) # frequency range of oscillation of interest
t = np.arange(0,len(x)/Fs,1/Fs) # time array
In [6]:
findpt_kwargs = {'filter_fn':nonshape.bandpass_default,
'filter_kwargs': {'w':3}}
define_true_oscillating_periods_kwargs = {'ampdiff_th':.5, 'timediff_th':.6}
df_P, df_T = shape.compute_shape_by_cycle(x, f_range, Fs,
findpt_kwargs=findpt_kwargs,
define_true_oscillating_periods_kwargs=define_true_oscillating_periods_kwargs)
In [11]:
# Let's look at 3 columns of df_T,
# which has the shape features for each peak-to-peak (trough-centered) cycle
df = df_T[['rdsym_time', 'sample_lastE', 'sample_nextE']]
df.head(10)
Out[11]:
In [12]:
rdsym_time_ts = np.zeros(len(x))
N_cycles = len(df)
for i in range(N_cycles):
rdsym_time_ts[df['sample_lastE'][i]:df['sample_nextE'][i]] = df['rdsym_time'][i]
In [13]:
plt.plot(rdsym_time_ts)
Out[13]:
In [ ]: